///////////////////////////////////////////////////////////////
///////** INDIGENOUS POLITICAL PARTICIPATION: ANALYSIS **//////
///////////////////////////////////////////////////////////////

// NOTES //
* Script last updated February 2025 
* Open data set created using syntax_vars_creation.do

* Standardize variables
foreach var of varlist indig parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest indig_population indigenousparty compvote {
summ `var'
gen `var'std = `var'/r(sd)
}

// MAIN MANUSCRIPT //

* Table 1. Predictors of Political Participation

	* Regress
	meqrlogit vote indigstd orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd || pais: || wave:
	est store m1
	meqrlogit protest indigstd orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd || pais: || wave:
	est store m2
	meqrlogit townmeeting indigstd orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd || pais: || wave:
	est store m3
	meqrlogit petitionlocal indigstd orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd || pais: || wave:
	est store m4
	meqrlogit contactlocal indigstd orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd || pais: || wave:
	est store m5
	meqrlogit contactfederal indigstd orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd || pais: || wave:
	est store m6
	meqrlogit contactcongress indigstd orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd || pais: || wave:
	est store m7
	meqrlogit campaign indigstd orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd || pais: || wave:
	est store m8
	meqrlogit polparty1 indigstd orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd || pais: || wave:
	est store m9
	
	* Create a table
	outreg2 [m1 m2 m3 m4 m5 m6 m7 m8 m9] using table_individual_lvl.doc, dec(3) replace
	
	* Re-run models w/ odds ratios for easier interpretation
	meqrlogit vote indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest || pais: || wave:, or
	est store m10
	meqrlogit protest indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest || pais: || wave:, or
	est store m11
	meqrlogit townmeeting indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest || pais: || wave:, or
	est store m12
	meqrlogit petitionlocal indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest || pais: || wave:, or
	est store m13
	meqrlogit contactlocal indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest || pais: || wave:, or
	est store m14
	meqrlogit contactfederal indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest || pais: || wave:, or
	est store m15
	meqrlogit contactcongress indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest || pais: || wave:, or
	est store m16
	meqrlogit campaign indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest || pais: || wave:, or
	est store m17
	meqrlogit polparty1 indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest || pais: || wave:, or
	est store m18
	
	* Create a table 
	outreg2 [m10 m11 m12 m13 m14 m15 m16 m17 m18] using table_1_or.doc, eform dec(3) replace

* Table SM3: Predictors of political participation with country-level factors
	* Note: Figures 2 and 3 in the main manuscript are based on these models but the table itself is reported in the Supplementary Material.
	
	melogit vote indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty indig##c.indig_population indig##indigenousparty || pais: || wave:
	est store m19	
	melogit protest indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty indig##c.indig_population indig##indigenousparty || pais: || wave: 
	est store m20
	melogit townmeeting indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty indig##c.indig_population indig##indigenousparty || pais: || wave:
	est store m21
	melogit petitionlocal indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty indig##c.indig_population indig##indigenousparty || pais: || wave:  
	est store m22
	melogit contactlocal indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty indig##c.indig_population indig##indigenousparty || pais: || wave:  
	est store m23
	melogit contactfederal indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty indig##c.indig_population indig##indigenousparty || pais: || wave:  
	est store m24
	melogit contactcongress indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty indig##c.indig_population indig##indigenousparty || pais: || wave: 
	est store m25
	melogit campaign indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty indig##c.indig_population indig##indigenousparty || pais: || wave: 
	est store m26
	melogit polparty1 indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty indig##c.indig_population indig##indigenousparty || pais: || wave: 
	est store m27
	
	* Create a table 
	outreg2 [m19 m20 m21 m22 m23 m24 m25 m26 m27] using table_sm3_with_country_factors.doc, eform dec(3) replace	
	
	* Create a coefficient plot (Figure 2)
	#delimit;
	coefplot (m19, label(Vote))  (m20, label(Protest)) (m21, label(Town Meeting)) (m22, label(Petition (local))) (m23, label(Contact (local))) (m24, label(Contact (federal))) (m25, label(Contact (congress))) (m26, label(Campaign)) (m27, label(Party Meeting)),
	drop(indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty _cons) xline(0) scheme(s1mono) title("Political Participation", span margin(9 6 3 0)
	size(medlarge)) scale(.85) name(coefplot, replace) saving(coefplot, replace);
	
	* Create an interaction plot: Marginal Effects of Being Indigenous on Voting by Population Share (Figure 3)
	melogit vote i.indig orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population i.indig##c.indig_population || pais: || wave:	
	margins, dydx(indig) at(indig_population=(.2 62.2)) vsquish
	marginsplot, yline(0)	

/// Table SM4: Individual-level predictors of political participation among Indigenous peoples
	* Note: Figure 5 in the main manuscript is based on these models but the table itself is reported in the Supplementary Material.	

	melogit vote orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd if indig == 1 || pais: || wave:
	est store m30
	melogit protest orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd if indig == 1 || pais: || wave:
	est store m31
	melogit townmeeting orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd if indig == 1 || pais: || wave:
	est store m32
	melogit petitionlocal orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd if indig == 1 || pais: || wave:
	est store m33
	melogit contactlocal orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd if indig == 1 || pais: || wave: 
	est store m34
	melogit contactfederal orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd if indig == 1 || pais: || wave:
	est store m35
	melogit contactcongress orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd if indig == 1 || pais: || wave:
	est store m36
	melogit campaign orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd if indig == 1 || pais: || wave:
	est store m37
	melogit polparty1 orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd if indig == 1 || pais: || wave:
	est store m38

	* Create a table
	outreg2 [m30 m31 m32 m33 m34 m35 m36 m37 m38] using table_sm4_indig_only.doc, dec(3) replace
	
	* Create a coefficient plot (Figure 5)
	#delimit;
	coefplot (m100, label(Vote))  (m101, label(Protest)) (m103, label(Town Meeting)) (m104, label(Petition (local))) (m105, label(Contact (local))) (m106, label(Contact (federal))) (m107, label(Contact (congress))) (m108, label(Campaign)) (m109, label(Party Meeting)),
	drop(indigstd leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd _cons var(_cons[pais] var(_cons[pais>wave]))) xline(0) scheme(s1mono) title("Political Participation", span margin(9 6 3 0)
	size(medlarge)) scale(.85) name(coeffplot3, replace) saving(fig_5_coefplot_of_table_sm4, replace);	
	
// SUPPLEMENTARY MATERIAL //

/// Table SM3: Predictors of political participation with country-level factors (see syntax above)

/// Table SM4: Individual-level predictors of political participation among Indigenous peoples (see syntax above)

/// Figure SM2. Predictors of political participation with parents’ language measure 

		melogit vote parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty parentslang_lax##c.indig_population parentslang_lax##indigenousparty || pais: || wave:
		est store m21a	
		melogit protest parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty parentslang_lax##c.indig_population parentslang_lax##indigenousparty || pais: || wave: 
		est store m22b
		melogit townmeeting parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty parentslang_lax##c.indig_population parentslang_lax##indigenousparty || pais: || wave:
		est store m23c
		melogit petitionlocal parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty parentslang_lax##c.indig_population parentslang_lax##indigenousparty || pais: || wave:  
		est store m24d
		melogit contactlocal parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty parentslang_lax##c.indig_population parentslang_lax##indigenousparty || pais: || wave:  
		est store m25e
		melogit contactfederal parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty parentslang_lax##c.indig_population parentslang_lax##indigenousparty || pais: || wave:  
		est store m26f
		melogit contactcongress parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty parentslang_lax##c.indig_population parentslang_lax##indigenousparty || pais: || wave: 
		est store m27g
		melogit campaign parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty parentslang_lax##c.indig_population parentslang_lax##indigenousparty || pais: || wave: 
		est store m28h
		melogit polparty1 parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty parentslang_lax##c.indig_population parentslang_lax##indigenousparty || pais: || wave: 
		est store m29i
		
		* Coefficient plot
		#delimit;
		coefplot (m_a, label(Vote))  (m_b, label(Protest)) (m_c, label(Town Meeting)) (m_d, label(Petition (local))) (m_e, label(Contact (local))) (m_f, label(Contact (federal))) (m_g, label(Contact (congress))) (m_h, label(Campaign)) (m_i, label(Party Meeting)),
		drop(orgmtg01std leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd _cons) xline(0) scheme(s1mono) title("Political Participation", span margin(9 6 3 0)
		size(medlarge)) scale(.85) name(coefplot_sm1, replace) saving(fig_sm2_coefplot, replace);

/// Figure SM3. Effects of cross-level interactions with parents’ language measure 

		#delimit;
		coefplot (m21a, label(Vote))  (m22b, label(Protest)) (m23c, label(Town Meeting)) (m24d, label(Petition Local Gov't)) (m25e, label(Contact Local Gov't)) (m26f, label(Contact Central Gov't)) (m27g, label(Contact Congress)) (m28h, label(Campaign)) (m29i, label(Party Meeting)),
		drop(parentslang_lax orgmtg01 left wealth female age edu_years religiosity2 rural trust polinterest compvote indig_population indigenousparty _cons) xline(0) scheme(s1mono) title("Political Participation", span margin(9 6 3 0)
		size(medlarge)) scale(.85) name(coeffplot2, replace) saving(fig_sm3_coefplot, replace);

/// Figure SM4. Individual-level predictors of political participation among people whose parents spoke an Indigenous language

		#delimit;
		coefplot (m100a, label(Vote))  (m101b, label(Protest)) (m103c, label(Town Meeting)) (m104d, label(Petition Local Gov't)) (m105e, label(Contact Local Gov't)) (m106f, label(Contact Central Gov't)) (m107g, label(Contact Congress)) (m108h, label(Campaign)) (m109i, label(Party Meeting)),
		drop(leftstd wealthstd femalestd agestd edu_yearsstd religiosity2std ruralstd truststd polintereststd _cons var(_cons[pais] var(_cons[pais>wave]))) xline(0) scheme(s1mono) title("Political Participation", span margin(9 6 3 0)
		size(medlarge)) scale(.85) name(coeffplot3, replace) saving(fig_sm4_coefplot, replace);
	
